﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using System.Diagnostics;

namespace DarkNeuron.Services.Input
{
// #if xbox
	public class ButtonKeyboardXBox : Button
	{
		protected Keys key;
		public Keys Key { get { return key; } set { Console.WriteLine("ButtonKeyboardXBox|Information:> Button key changed from {0} to {1}.", key, value); key = value; } }
		protected PlayerIndex playerIndex;
		public PlayerIndex PlayerIndex { get { return playerIndex; } set { Console.WriteLine("ButtonKeyboardXBox|Information:> Button player index changed from {0} to {1}.", playerIndex, value); playerIndex = value; } }


		public ButtonKeyboardXBox(string name, Keys key, PlayerIndex playerIndex)
			: base(name, ButtonDevice.KeyboardXBox)
		{
			Console.WriteLine("ButtonKeyboardXBox|Information:> New ButtonKeyboardXBox \"{0}\" is being initialized...", Name);

			bool pass = true;
			this.key = key;
			this.playerIndex = playerIndex;

			pass = ButtonManager.AddButton(this);

			if (pass) Console.WriteLine("ButtonKeyboardXBox|Information:> ButtonKeyboardXBox \"{0}\" is successfully initialized.", Name);
			else Console.WriteLine("ButtonKeyboardXBox|Error:> ButtonKeyboardXBox \"{0}\" is NOT successfully initialized!", Name);
		}


		public override void Update(GameTime gameTime)
		{
			if (Enabled)
			{
				// Sets current button states
				previousButtonState = currentButtonState;
				currentButtonState = GameInput.KeyboardsXBox[(int)playerIndex].IsKeyDown(key) ? ButtonState.Down : ButtonState.Up;
			}


			base.Update(gameTime);
		}
	}
// #endif
}
